<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pe="http://primefaces.org/ui/extensions" >
<h:head>
	<title>Package Composition</title>
	<h:outputStylesheet name="css/composition.css" />
</h:head>
<h:body>
	<h:link value="PERSONAL HOME" outcome="index" />
	<h:form id="baseProductsBaseInfoForm">
	<p:messages id="msgs" />
	<br />
	<p:outputLabel value="A coherent travel package involves a maximum of 1 hotel, 2 transports, and any number of excursions. The expiry date,
		the begin date, and the end date must be in order and temporally correct." />
	<p:panel id="panelBaseProductsBaseInfo" header="Package reservations info">  
        	<h:panelGrid columns="3">
        		<h:outputLabel for="expiry" value="Expiry date: "></h:outputLabel>
				<p:outputLabel id="expiry" value="#{addCustomerPackage.travelPackage.expiry}" label="Expiry date" >
					<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
				</p:outputLabel>
				<h:outputLabel value="" />
				
				<h:outputLabel for="price" value="Base price: "></h:outputLabel>
				<p:outputLabel id="price" value="#{addCustomerPackage.travelPackage.basePrice} €" label="Base price" />
        		
	 			<h:outputLabel for="start" value="Begin date: "></h:outputLabel>
				<p:calendar id="start" value="#{addCustomerPackage.startDate}" pattern="dd/MM/yyyy HH:mm" disabled="#{addCustomerPackage.submitDisabled}"
					required="true" requiredMessage="Please enter the begin date."
					converterMessage="Invalid begin date." label="Start date" >
					<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
				</p:calendar>
				<p:message for="start" display="icon" />
				
				<h:outputLabel for="end" value="End date: "></h:outputLabel>
				<p:calendar id="end" value="#{addCustomerPackage.endDate}" pattern="dd/MM/yyyy HH:mm" disabled="#{addCustomerPackage.submitDisabled}"
					required="true" requiredMessage="Please enter the end date."
					converterMessage="Invalid end date." label="End date" >
					<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
				</p:calendar>
				<p:message for="end" display="icon"/>
			
				<h:outputLabel for="reservations" value="Reservations:  "></h:outputLabel>
				<p:inputText id="reservations" value="#{addCustomerPackage.reservations}" disabled="#{addCustomerPackage.submitDisabled}"
					required="true" requiredMessage="Please enter the reservations." label="Reservations" >
				 	<p:slider for="reservations" minValue="1" disabled="#{addCustomerPackage.submitDisabled}"/></p:inputText>
				<p:message for="reservations" display="icon"/>
			
	 			<p:commandButton id="buttonReservationsInfo" update="@form :baseProductsForm" value="Submit base info" disabled="#{addCustomerPackage.submitDisabled}"
					action="#{addCustomerPackage.sendBaseData()}" />
				<p:button id="buttonResetInfo" outcome="addPackage" value="Reset all module info" />
			</h:panelGrid>
	</p:panel>
	</h:form>
	
	<h:form id="baseProductsForm">
	<p:messages id="msgss" /> 
	<p:panel id="panelBaseProducts" header="Base products" >
	<p:tabView effect="blind" id="tabBaseProducts" >
		<p:tab id="tabHotels" title="HOTELS">
            <h:panelGrid columns="2" cellpadding="10" >
                <p:pickList id="hotelsPickList" value="#{addCustomerPackage.hotels}" var="hotel"
                    itemValue="#{hotel}" itemLabel="#{hotel.id}" converter="hotelConverter"  
                    showSourceFilter="true" showTargetFilter="true" filterMatchMode="contains" >  
  
        			<f:facet name="sourceCaption">Available hotels</f:facet>  
        			<f:facet name="targetCaption">Selected hotels</f:facet>  
 					
        			<p:column >
        				Name - Address: <br/>
        				<h:outputLabel title="#{hotel.description}" value="#{hotel.name} - #{hotel.address}" />
        			</p:column>
        			
        			<p:column >
        				Begin: <br/>
        				<h:outputLabel title="#{hotel.description}" value="#{hotel.startTrip}" >
        					<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
        				</h:outputLabel>
        			</p:column>
        	
        			<p:column >
        				End: <br/>
        				<h:outputLabel title="#{hotel.description}" value="#{hotel.endTrip}" >
        					<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
        				</h:outputLabel>
        			</p:column>
        			
        			<p:column >
        				Price: <br/>
        				<h:outputLabel title="#{hotel.description}" value="#{hotel.price}€" />
        			</p:column>
  				</p:pickList>  
            </h:panelGrid>
		</p:tab>
		
		<p:tab id="tabTransports" title="TRANSPORTS">
            <h:panelGrid columns="2" cellpadding="10"> 
             	<p:pickList id="transportsPickList" value="#{addCustomerPackage.transports}" var="transport"
                    itemValue="#{transport}" itemLabel="#{transport.id}" converter="transportConverter"  
                    showSourceFilter="true" showTargetFilter="true" filterMatchMode="contains" >  
  
        			<f:facet name="sourceCaption">Available transports</f:facet>  
        			<f:facet name="targetCaption">Selected transports</f:facet>  
 					
        			<p:column >
        				Company: <br/>
        				<h:outputLabel title="#{transport.description}" value="#{transport.company}" />
        			</p:column>
        			
        			<p:column >
        				Begin: <br/>
        				<h:outputLabel title="#{transport.description}" value="#{transport.startTrip}" >
        					<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
        				</h:outputLabel>
        				<br />
        				<h:outputLabel value="#{transport.departureCity}" ></h:outputLabel>
        			</p:column>
        			
        			<p:column >
        				End: <br/>
        				<h:outputLabel title="#{transport.description}" value="#{transport.endTrip}" >
        					<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
        				</h:outputLabel>
        				<br />
        				<h:outputLabel value="#{transport.arrivalCity}" ></h:outputLabel>
        			</p:column>
        			
        			<p:column >
        				Price: <br/>
        				<h:outputLabel title="#{transport.description}" value="#{transport.price}€" />
        			</p:column>
  				</p:pickList>
            </h:panelGrid>  
   		</p:tab>
   		
		<p:tab id="tabExcursions" title="EXCURSIONS">
            <h:panelGrid columns="2" cellpadding="10">
             	<p:pickList id="excursionsPickList" value="#{addCustomerPackage.excursions}" var="excursion"
                    itemValue="#{excursion}" itemLabel="#{excursion.id}" converter="excursionConverter"  
                    showSourceFilter="true" showTargetFilter="true" filterMatchMode="contains" >  
  
        			<f:facet name="sourceCaption">Available excursions</f:facet>  
        			<f:facet name="targetCaption">Selected excursions</f:facet>
 				
        			<p:column >
        				Organizer: <br/>
        				<h:outputLabel title="#{excursion.description}" value="#{excursion.organizer}" />
        			</p:column>
        			
        			<p:column >
        				Begin: <br/>
        				<h:outputLabel title="#{excursion.description}" value="#{excursion.startTrip}" >
        					<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
        				</h:outputLabel>
        				<br />
        				<h:outputLabel value="#{excursion.startAddress}" ></h:outputLabel>
        			</p:column>
        			
        			<p:column >
        				End: <br/>
        				<h:outputLabel title="#{excursion.description}" value="#{excursion.endTrip}" >
        					<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
        				</h:outputLabel>
        			</p:column>
        			
        			<p:column >
        				Price: <br/>
        				<h:outputLabel title="#{excursion.description}" value="#{excursion.price}€" />
        			</p:column>
  				</p:pickList>
            </h:panelGrid>
    	</p:tab>
    </p:tabView>
 
    <p:outputPanel id="panelPackageInfo" header="Package base info">  
        	<h:panelGrid columns="4">
        		<h:outputLabel for="description" value="Description: "></h:outputLabel>
				<p:inputTextarea id="description" value="#{addCustomerPackage.description}" label="Description"
					rows="6" cols="36" maxlength="1024"/>
				<p:message for="description" display="icon"/> 
			</h:panelGrid>
	</p:outputPanel>
	
	<p:commandButton id="buttonComposePackage" update="buttonComposePackage :baseProductsForm:msgss" value="Submit package" disabled="#{addCustomerPackage.composeDisabled}"
					action="#{addCustomerPackage.composePackage()}" />
	</p:panel>
	</h:form>
</h:body>
</html>